package day0925;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
class  Student  implements  Comparable{
    int stuNo;

    public Student(int stuNo) {
        this.stuNo = stuNo;
    }
    public int compareTo(Object o) {//this的值 -  o的值就是升序排序
        return   ((Student)o).stuNo  - this.stuNo ;
    }
}





public class T1_2 {
    public static void main(String[] args) {
        //TreeMap可以对元素进行排序： 根据元素的key进行排序
        //key:  new Student("big2-1001")   要进行排序，实现一个Comparable
        Map<Student,String> map=new TreeMap();
        map.put( new Student(1001),  "张三");
        map.put( new Student(1002),  "李四");


        Set<Map.Entry<Student,String>>  set=map.entrySet();
        for(Map.Entry<Student,String> e:set){
            System.out.println("e.getKey().stuNo = " + e.getKey().stuNo);
        }
    }
}
